#include "ScnsOv7725.c.h"

#if defined(SCNS_OV7725_ENABLE)&&SCNS_OV7725_ENABLE==1

#include "ScnsIic.h"
#include "dcmi.h"
#include "ScnsTimer.h"
#include "ScnsPcf8574.h"

const ScnsBspOv7725Config scnsBspOv7725Config[SCNS_OV7725_MAX]={
};

ScnsStatus scnsBspOv7725Init(ScnsOv7725Enum ov7N)
{
    DCMI_RESET_GPIO_Port->BSRR=(0)?(DCMI_RESET_Pin):(DCMI_RESET_Pin<<16);
    scnsDelayMs(20);
    scnsPcf8574WriteBit(SCNS_PCF8574_1,2,0);
    scnsDelayMs(5);
    DCMI_RESET_GPIO_Port->BSRR=(1)?(DCMI_RESET_Pin):(DCMI_RESET_Pin<<16);
    scnsDelayMs(5);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspOv7725Write(ScnsOv7725Enum ov7N,const uint8*addr,uint8 addrLen,const uint8*data,uint8 dataLen)
{
    return scnsIicWriteTick(SCNS_IIC_SOFT_DCMI,0X78,addr,addrLen,data,dataLen,32);
}

ScnsStatus scnsBspOv7725Read(ScnsOv7725Enum ov7N,const uint8*addr,uint8 addrLen,uint8*data,uint8 dataLen)
{
    return scnsIicReadTick(SCNS_IIC_SOFT_DCMI,0X78,addr,addrLen,data,dataLen,32);
}

ScnsStatus scnsBspOv7725DmaStart(ScnsOv7725Enum ov7N,uint8*ptr,uint32 size)
{
    scnsCheckSTM32HALStatus(HAL_DCMI_Start_DMA(&hdcmi,DCMI_MODE_SNAPSHOT,(uint32_t)ptr,size/4));return SCNS_STATUS_OK;
}

#endif
